package bytestream;

import java.io.*;

public class OutPutStreamDemo {
    public static void main(String[] args) {
        OutputStream outputStream=null;
        try {
            //创建字节流输出对象
            outputStream=new FileOutputStream("a.txt",true);
            String s="HelloWorld";
            byte[] b=s.getBytes();//获得字符串的字节数组
            //有数组就要遍历

            outputStream.write(b);//单个字节的写入


        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (outputStream!=null) {
                try {
                    outputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}
